#version 410
#extension GL_EXT_gpu_shader4 : enable

out vec4 FragColor;
in vec3 tePosition;
in vec3 teNormal;
in vec3 teParam;
//in vec3 gTriDistance;
//in vec3 gPatchDistance;
//in float gPrimitive;
uniform struct {
vec3 LightPosition;
vec3 DiffuseMaterial;
vec3 AmbientMaterial;
} shading;

float amplify(float d, float scale, float offset)
{
    d = scale * d + offset;
    d = clamp(d, 0, 1);
    d = 1 - exp2(-2*d*d);
    return d;
}

void main()
{
	vec3 dNorm;

	dNorm = teNormal;
	//vec3 dPos0 = min(dFdx(tePosition),-dFdx(tePosition));
	//vec3 dPos1 = min(dFdy(tePosition),-dFdy(tePosition));
	//dNorm = cross(dPos0, dPos1);


    vec3 N = normalize(dNorm);
    vec3 L = shading.LightPosition;
    float df = abs(dot(N, L));
    vec3 color = shading.AmbientMaterial + df * shading.DiffuseMaterial/*teParam*/;
	//color = teParam;

	FragColor = vec4(color, 1.0);	
}
